//
//  HYTabBarViewController.m
//  HaiYue
//
//  Created by skyline on 2017/12/14.
//  Copyright © 2017年 skyline. All rights reserved.
//

#import "HYTabBarViewController.h"
#import "HYNavigationController.h"
#import "HYViewController.h"
@interface HYTabBarViewController ()

@end

@implementation HYTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //    self.delegate = self;
    [self setupViewController];
    [self setupColor];
}

- (void)setupColor
{
    self.tabBar.tintColor =  RGBA(235, 50, 35, 1);
    UIView *color_view = [[UIView alloc]initWithFrame:self.tabBar.bounds];
    color_view.backgroundColor = [UIColor whiteColor];
    [self.tabBar insertSubview:color_view atIndex:0];
    self.tabBar.unselectedItemTintColor = RGBA(114, 115, 116, 1);
}
//
- (void)setupViewController
{
#warning 修改
    NSArray *VC = nil;
    NSArray *image = nil;
    NSArray *selectedImage = nil;
    NSArray *titles = nil;
    if (IS_APPStore)
    {
        VC = @[@"HYGameViewController", @"HYServerViewController", @"HYTradeViewController", @"HYMyAssetsViewController"];
        image = @[@"user",@"user",@"user",@"user",@"user"];
        selectedImage = @[@"userRed",@"userRed",@"userRed",@"userRed"];
        titles = @[@"游戏",@"玩新服",@"交易",@"我的资产"];
        NSLog(@"上架app store 版本");
    }
    else if (IS_QiYeQian)
    {
        VC = @[@"HYGameViewController", @"HYServerViewController", @"HYMyAssetsViewController"];
        image = @[@"main_game_normal",@"main_kaifu_normal",@"main_mine_normal"];
        selectedImage = @[@"main_game_selecter",@"main_kaifu_selecter",@"main_mine_selecter"];
        titles = @[@"游戏",@"玩新服",@"我的资产"];
        NSLog(@"企业签名 版本");
    }
    
    for (int i = 0; i < VC.count; i ++) {
        
        Class VCclass = NSClassFromString(VC[i]);
        HYViewController *vc = [VCclass new];
        vc.tabBarItem = [[UITabBarItem alloc]initWithTitle:titles[i] image:[[UIImage imageNamed:image[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:selectedImage[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        
        HYNavigationController *navi = [[HYNavigationController alloc]initWithRootViewController:vc];
        [self addChildViewController:navi];
        
    }
}

//- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
//{
//
//    return YES;
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
